"use strict";
cc._RF.push(module, 'e30edC8QZxNipBdOEDofyAn', 'Bullet');
// Script/Bullet.js

"use strict";

// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        flySpeed: 0, //子弹飞行速度
        flyTime: 0, //飞行时间
        flyLength: 0, //飞行距离
        type: 0, //子弹类型
        isGood: 0, //敌军子弹/我军子弹
        powerNum: 0 //子弹威力
    },

    //子弹向上飞行方法--我方
    zidanFlyUpAction: function zidanFlyUpAction() {
        var flyUp = cc.moveBy(this.flyTime, cc.v2(0, this.flyLength));
        //var flyUp = cc.moveBy(this.flyTime, cc.v2(0, this.flyLength)).easing(cc.easeCubicActionIn());
        return flyUp;
    },

    //子弹向下飞行方法--敌方
    zidanFlyDownAction: function zidanFlyDownAction() {
        var flyDown = cc.moveBy(this.flyTime, cc.v2(0, -this.flyLength));
        return flyDown;
    },

    doClean: function doClean() {
        if (this.node.y > 400 || this.node.y < -400 || this.node.x > 240 || this.node.x < -240) {
            //this.node.removeFromParent();
            this.node.destroy();
            //console.log("子弹越出边界自动销毁!!");
        }
        /*var worldPos = this.parent.convertToWorldSpaceAR(armatureNode.getPosition());
              if (
                  worldPos.x < -100 || worldPos.x >= cc.visibleRect.width + 100 ||
                  worldPos.y < -100 || worldPos.y >= cc.visibleRect.height + 100
              ) {
                  this.doClean();
                  return true;
              }	*/
    },

    onLoad: function onLoad() {
        if (this.isGood == 0) {
            //我方
            this.node.runAction(this.zidanFlyUpAction()); //子弹飞行移动
        } else if (this.isGood == 1) {
            //敌方
            this.node.runAction(this.zidanFlyDownAction());
        }
    },
    start: function start() {},
    update: function update(dt) {
        this.doClean();
    }
});

cc._RF.pop();